/* Représente un composite, c'est-à-dire un sous-arbre qui 
 */


#include "DtdComposite.h"

#include <cstddef>


DtdComposite::DtdComposite()
	: DtdNode(NODE_COMPOSITE), compositeType(SEQ)
{
	/* Bloc vide */
}

DtdComposite::~DtdComposite()
{
	for ( it = children.begin(); it != children.end(); it++ )
	{
		delete *it;
	}
}

/* Ajoute un gosse */
void DtdComposite::appendChild(DtdNode *p_child)
{
	p_child->parent = this;
	children.push_back(p_child);
}

/* Ajoute des gosses */
void DtdComposite::appendChildren(std::list<DtdNode*> &p_children)
{
	std::list<DtdNode*>::iterator it;

	for (it = p_children.begin(); it != p_children.end(); it++)
	{
		(*it)->parent = this;
		children.push_back(*it);
	}
}

/* Permet de traverser la liste des enfants */
void DtdComposite::setItToBeg()
{
	it = children.begin();
}

DtdNode* DtdComposite::getItNext()
{
	DtdNode *n = *it;
	it++;
	return n;
}

bool DtdComposite::itContinue()
{
	return (it != children.end());
}
